package com.jason.library.scope

/**
 * @description: ApplyScopeFunctionMain
 *
 * @author ChenBaoyang
 * @date 6/30/21 15:02
 */
object ApplyScopeFunctionMain {

    @JvmStatic
    fun main(array: Array<String>) {
        applyCharacteristic1()
    }
}

/**
 * 前面看到的 let、with 和 run 函数返回的值都是 R。但是，apply 和下面查看的 also 返回 T，apply的上下文是'this'
 */
fun applyCharacteristic1() {
    val book = Book().apply {
        name = "《计算机网络》"
        price = 40
    }
    println(book)
}

